As mentioned earlier, most QuickTime VR Manager functions operate on a QuickTime VR movie instance (defined by the QTVRInstance data type), which identifies a particular QuickTime VR movie. You can get a QuickTime VR movie instance by calling the QTVRGetQTVRInstance function, as illustrated in Listing 2-2 .
Listing 2 Getting a QuickTime VR movie instance
QTVRInstance MyGetQTVRInstanceFromMC (MovieController theController)
{
Track myTrack = nil;
QTVRInstance myInstance = nil;
Movie myMovie;
//Get the movie from the movie controller.
myMovie = MCGetMovie(theController);
if (myMovie) {
//Get the first QTVR track in the movie.
myTrack = QTVRGetQTVRTrack(myMovie, 1);
//Get a QTVR instance for that QTVR track.
if (myTrack) {
QTVRGetQTVRInstance(myInstance, myTrack, theController);
//Set our units to be degrees.
if (myInstance)
QTVRSetAngularUnits(myInstance, kQTVRDegrees);
}
}
return(myInstance);
}
To get a QuickTime VR movie instance, you first need to obtain a QTVR track, a special type of QuickTime track that maintains a list of the nodes in the scene. A single QuickTime movie file can contain more than one QuickTime VR scene and hence more than one QTVR track, so you need to specify which QTVR track you want by calling the QTVRGetQTVRTrack function with the index of the desired track. Listing 2-2 simply gets the first QTVR track in the specified movie.
Movies made with QuickTime VR 1.0 do not contain a QTVR track. When you call QTVRGetQTVRTrack with such a movie, the function returns the appropriate QuickTime track.
After getting the desired QTVR track, the MyGetQTVRInstanceFromMC function defined in Listing 2-2 calls the QTVRGetQTVRInstance function to obtain a QuickTime VR movie instance. Finally, MyGetQTVRInstanceFromMC calls QTVRSetAngularUnits to ensure that all angles passed to QuickTime VR functions are interpreted as degrees.
A QuickTime VR movie instance is essentially a pointer to a data structure maintained privately by QuickTime VR. You obtain a movie instance by calling QTVRGetQTVRInstance , but you do not need to dispose of that instance. A QuickTime VR movie instance remains valid until you dispose of the QuickTime movie controller (by calling DisposeMovieController ).
| Previous | Chapter Contents | Chapter Top | Next |